function addLoadEvent(newOnload)
{
	var oldOnload = window.onload;
	if (typeof(window.onload) != "function")
	{
		window.onload = newOnload;
	}
	else
	{
		window.onload = function()
		{
			oldOnload();
			newOnload();
		}
	}
}

function scrollDivTo(divId, childId)
{
	var top = 0;
	var element = document.getElementById(childId);
	while (element.id != divId)
	{
		top += element.offsetTop;
		element = element.offsetParent;
	}
	document.getElementById(divId).scrollTop = top;
}

function selectAll()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true &&
			(inputs[index].id.indexOf("Unsent") > 0 || inputs[index].id.indexOf("Sent") > 0 ||
			inputs[index].id.indexOf("NoticeQueued") > 0 ||
			inputs[index].id.indexOf("ReminderQueued") > 0 ||
			inputs[index].id.indexOf("Reminded") > 0 ||
			inputs[index].id.indexOf("Acknowledged") > 0))
			{
			    inputs[index].checked = true;
			}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectUnsent()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
			inputs[index].checked = inputs[index].id.indexOf("Unsent") > 0;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectUnacknowledged()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
		    inputs[index].checked = (inputs[index].id.indexOf("Sent") > 0 ||
			    inputs[index].id.indexOf("NoticeQueued") > 0);
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function deselectAll()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true &&
			(inputs[index].id.indexOf("Unsent") > 0 || inputs[index].id.indexOf("Sent") > 0 ||
			inputs[index].id.indexOf("Acknowledged") > 0 ||
			 inputs[index].id.indexOf("NoticeQueued") > 0 ||
			 inputs[index].id.indexOf("ReminderQueued") > 0 ||
			 inputs[index].id.indexOf("Reminded") > 0))
		{
			inputs[index].checked = false;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectInternalUnsent()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
			inputs[index].checked = inputs[index].id.indexOf("Unsent") > 0 &&
				inputs[index].id.indexOf("Internal") > 0;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectInternalUnack()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
			inputs[index].checked = (inputs[index].id.indexOf("Sent") > 0 || inputs[index].id.indexOf("NoticeQueued") > 0) &&
				inputs[index].id.indexOf("Internal") > 0;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectExternalUnsent()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
			inputs[index].checked = inputs[index].id.indexOf("Unsent") > 0 &&
				inputs[index].id.indexOf("External") > 0;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}

function selectExternalUnack()
{
	var inputs = document.getElementsByTagName("input");
	for (var index = 0; index < inputs.length; index ++)
	{
		if (inputs[index].type == "checkbox" && inputs[index].disabled != true)
		{
			inputs[index].checked = (inputs[index].id.indexOf("Sent") > 0 || inputs[index].id.indexOf("NoticeQueued") > 0) &&
				inputs[index].id.indexOf("External") > 0;
		}
		else if (inputs[index].type == "button")
		{
			inputs[index].blur();
		}
	}
}
